package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

/**
 * @author 老杨
 * @version 1.0
 *
 */
@Slf4j
@Api(tags = "管理 店铺接口")
@RestController("userShopController")
@RequestMapping("/user/shop")
public class ShopController {

    @Autowired
    RedisTemplate redisTemplate;

    @ApiOperation(value ="查询 店铺营业状态")
    @GetMapping("/status")
    public Result<Integer> businessStatus(){

        //直接 使用方法 查询 redis 的数据即可
        ValueOperations valueOperations = redisTemplate.opsForValue();
       Integer shop_status = (Integer)valueOperations.get("SHOP_STATUS");
        log.info("查询的店铺状态 {}",shop_status == 1? "营业中":"休息中");
        return Result.success(shop_status);
    }


}
